This invention relates to use of a microcontroller to read/write data from/to a plurality of tracks contained on a magnetic stripe value card. More particularly, but not by way of limitation, this invention relates to a system and method for reading and writing data to a magnetic striped card with the use of a microcontroller.
The use of magnetic cards in modern society is well documented. For instance, credit cards are used throughout the worlds. The number of daily transaction using magnetic stripe cards has increased. Business establishments such as supermarkets, stores, gas stations, restaurants, and hotels are providing means to accept credit cards and debit cards as a common way to do business. The applications of magnetic stripe cards in e-commerce, and point of sale terminals drive the technology toward more secure and more economical ways of reading and writing of the magnetic stripe cards.
Recently, a new type of card, sometimes referred to as a smart card, has been used by businesses. Generally, the smart card contains a microprocessor that allows for the reading and writing of data as the card is inserted into a card reader. However, the minimum price of a plastic card is about $2 which is much more expensive than the price of a plastic magnetic stripe card.
Kobayashi et al have described (U.S. Pat. No. 4,304,992) magnetic cards with a timing track or clocking marker along the length of the magnetic stripe can be extended for reader/writer systems to handle speed variation of the card during read/write process. Magnetic heads are moved in sliding contact with the magnetic strips while timing signal that match the speed of the card is obtained from the timing track through detectors such as photo-sensors. Other prior art devices have tried to extract the timing clock from the data on the card using logic gated design.
The read/write system for debit card applications of digital logic design is very complex. Also, when the distance between write head and read head along the magnetic stripe is less than a bit cell length, the written part of the magnetic stripe will shift after each usage. For example, if the distance between read head and write head is one half bit cell distance and the debit card is used 100 times, the flux data on the stripe will shift 1.2 cm. The data flux reversal on the track-2 of the magnetic stripe will shift 1.2 cm.
The wide spread use of credit/debit cards will contribute to bottle necking of the communication lines and also will increase the seriousness of the network security. Thus, there is a need for development of stand alone reader/writer systems that will ease the above concerns. There is also a need for storing data locally, which data can then be sent in less congested times of network use to the appropriate destinations. Further, there is a need for more security that can be embedded into the system by software which in turn will reduce the cost and increase the reliability of the system.
Thus, there is a need for a magnetic card read/writer for debit card applications that will use the written data on the card to accommodate the variation of speed in swipe/insertion utilizing a general use microcontroller. Also, there is a need for a system and method for magnetic card applications that allow for fast read and write operations. The invention herein disclosed fulfills that need, and many others, as will be readily apparent from a reading of this disclosure.
The novel debit card read/write controller consists of a microcontroller device, a read only memory TOM) means, and a dynamic random access memory (DRAM) means. In the preferred embodiment, all of the components can be integrated into one dedicated chip. The integration of the magneto resistive (MR) read head/thin-film write head with the dedicated chip is described. The controller includes means for reading and writing into magnetic card media. Additionally, a process to integrate all components and chips into a single chip along with the read/write head is disclosed.
The controller may further comprise circuitry means for implementing the microcontroller chip to read and write to the magnetic card media. The microcontroller includes an input capture port for storing data read from the card, and the microcontroller can continually pole the input capture pins for an event to occur. In the most preferred embodiment, the main 16-bit free-running timer system of the MC68C11 series microcontroller has three input capture lines, five output-compare lines, and a real-time interrupt function. The newer version of the MC68C11 allows one output-compare channel to reconfigure as a fourth input capture line. Input lines are used to record timing edges.
The microcontroller operates in an expanded mode and has a memory map from 0000h to FFFFh. The first 256 bytes in all modes reside in the DRAM, a 64 byte register block in the range 1000h to 103Fh, and the final 2000 bytes are in an electrically erasable read only memory (EEPROM). The expanded mode allows for external chips DRAM or EEPROM to be addressed in the remaining ranges of 0100h-0FFFh and 1040h-B7FFh.
In the preferred embodiment, the executable code is stored in the EEPROM beginning at 8000h. The controller further comprises a signal conditioning circuit in a three stage process. In the preferred embodiment, the card contains three magnetic card media tracks. Additionally, the controller can contain output compare function means for comparing the time of the free running clock to match the time in the output compare register to toggle an output pin at each flux reversal to write.
A method for reading and writing to a magnetic strip located on a card is also disclosed. The method comprises providing a message to insert a card containing a magnetic card media and polling the input capture port for an event to occur. The card is inserted into a card reader, with the card reader being operatively associated with a MR read head and thin-film write head. The magnetic card media is passed underneath the MR head, and the information on the magnetic card media is stored in the form of a plurality of magnetic flux reversals. Changes in the resistance is detected by the MR head as the card moves under the MR head which in turn generates an analog signal. The analog signal is conditioned and amplified.
The signal is conditioned to a square wave. The square wave will include time edges containing rising and falling edge data, and the method further comprises storing a time edge at which transitions of the square wave occurs via the microcontroller by means of the input capture ports, with the time data of the edge being stored to the RAM. The method further includes extracting the binary information from the time edges and storing the extracted binary information in the RAM.
In one of the embodiments, the step of polling the input capture ports includes continually checking an interrupt pin to determine if the end of the card has been reached. It should be noted that in one embodiment this may be performed with an optical sensor, and in a second embodiment this may be performed with a micro-switch. The method further includes sending a low signal to an active low IRQ pin from the card reading device, and detecting the low signal by the program. Next, the interrupt service subroutine is entered and the interrupt vector (which is located at the memory address from FFF2h to FFF3h) is retrieved.
In one of the embodiments herein disclosed, the step of conditioning and amplifying the signal includes amplifying the signal with operational amplifiers until the signal is in the form of +5V to xe2x88x925V analog signal. The signal is then passed through a schmitt trigger and a diode so that the signal is in a digital format (using the TTL logic level) which is the form necessary for use by the microcontroller.
A method of reading from a magnetic striped card with a debit card read/write controller is also disclosed. The method comprises producing a waveform that consist of a series of rising and falling edges representing a series of flux reversals, and extracting a time based on whether a flux reversal occurs between a clocking transition. Binary data representative of the flux reversals is generated, and wherein an 0 is generated if no flux reversal occurs between the clocking transition and a 1 is generated if a flux reversal occurs between the clocking transition. The method includes waiting in a loop until an edge has been detected. The time of each transition is recorded as either a rising or falling edge of the incoming signal via the input capture port.
The method includes detecting when the entire track has been read and exiting from the loop. The method includes storing the time of the rising or falling edges and holding the address value corresponding to the last memory location and storing the time in a counter.
In one of the embodiments, the step of generating binary data includes transforming the flux data to binary data, and the method further comprises measuring the time between clocking transitions to calculate a pulse width time, and wherein if the pulse width time of the current signal is greater than a predetermined expected time, an 01 is generated representing a missing flux reversal between the clocking transition. The generated binary data 01 is stored in memory, and the measured time between clocking transitions is used to calculate a pulse width time, and if the pulse width of the current signal is less than the predetermined expected time, a 1 is generated representing a flux reversal between the clocking transition thereby generating a 1.
The method further includes decoding the entire waveform on the magnetic strip by proceeding through the array held at the first time buffer and computing each pulse width as Ti-Ti-1, then comparing the value to the predetermined expected time. If the pulse width 2 is greater than the expected time, the 01 is shifted into memory at flux buffer 1, and if pulse width 2 is less than the expected time, a 1 is shifted into memory. Thereafter, the expected time is recomputing every time an 01 or 11 combination is found.
The method further comprises extracting the binary information from the data held at the flux buffer, and wherein the binary information is extracted by shifting data held at the flux buffer once to the left, checking the carry bit, and thereafter, shifting the data held at the flux buffer left again, until a 1 is held in the carry flag. Next, the binary buffer array is incremented with a counter so that when a character is full, the next byte in the array is used. This routine will be exited, and the data is held in the memory at the binary buffer. A parity check for each data character and a longitudinal redundancy character (LRC) check is performed.
In one of the embodiments, the controller comprises a read head and write head placed exactly one half of a clocking transition apart from each other, and the method further comprises writing to the magnetic stripe(s). The step of writing includes the read head detecting the signal that was just written, and directing the write head what to do next. The method further comprises recording the times for successive edges on the incoming binary data, determining the period and/or pulse width of the signal, measuring a period, and measuring a pulse width. The step of measuring the period includes capturing two successive edges of the same polarity and the step of measuring the pulse width includes capturing two alternate polarity edges.
The method may further include polling the input capture port and latching the time to the microcontroller that an edge has been detected. Then, the time of that event is recorded in a memory buffer and wherein the polling loop simply detects whether a read has occurred and inside of the read subroutine, the next write must either take place or be programmed to take place. Thereafter, the method compares the time of the free running clock with the output compare (OC) register, and the time of the free running clock is matched with the OC register and the output pin is toggled to cause the write head to write to the magnetic stripe.
In the most preferred embodiment of this application, a process of writing to a magnetic stripe on a card with the integration of a microcontroller is also disclosed. In this embodiment, the MR read head and the write head are placed three times a bit cell distance apart and wherein the bit cell distance is defined as the distance between the two clocking flux transitions. The process starts with initialization to set all of the parameters (memory locations) to their initial values. The microcontroller waits to detect a transition. Once a positive transition or negative transition is detected, the transitions timing value is stored in a word in the memory address designated as CURR. If the detected edge is the first edge, a word in memory called FIRST is set to one. The content of CURR is stored in memory location PREV and then it waits for the next transition to occur.
Once the next transition occurred, its timing is stored in CURR. The current pulse time, TC, is calculated as the difference between the two detected edges. From the previous pulse width, TP, the expected pulse width, TE, is calculated. TE is set to 75% of the PREV pulse width, TP.
The value of the current pulse width, TC, is compared with the value of the expected pulse width, TE. If the current pulse width, TC, is greater than the expected time, TE, a ZERO bit is detected. Then it checks to see if FORCE is set to one, if answer is yes, a transition is forced to the output and FORCE is set to zero. The pulse width for ZERO bit, TZ, is set equal to the current pulse width, TC. The previous pulse width, PREV, is updated to the current pulse width, CURR.
Otherwise, if the current pulse width, TC, is less than the expected time, TE, a ONE bit is detected. It checks the value of flag called SKIP. If SKIP is equal to one, it updates the PREV by setting it equal to the current pulse width, CURR, and calculates the new ZERO bit pulse width, TP=2*TC, and sets the value of SKIP equal to zero and checks the value of the counter to see if write process is over or it should wait to detect another transition.
If SKIP value is equal to zero, it checks FORCE to see if a transition should be forced. If yes, it forces a transition and resets the FORCE to zero. It calculates the value for ZERO as bit TZ=2*TC and set, PREV=CURR, and sets SKIP equal to one. Next, the value of write-data (N) is checked. If it is equal to zero, the time of a transition is scheduled when the main time of micro controller reaches to the time equal to the sum of CURR and the ZERO bit pulse width. Otherwise, the time of a transition is scheduled when the main time of the microcontroller reaches to the time equal to the sum of CURR and the ZERO bit pulse width divided by two. It sets the value of FORCE equal to one. The counter""s value is decreased by one to take into account that one more bit is written. If the counter value is not equal to zero, it waits to detect another transition otherwise the write process is over.
Although dedicated controllers, including microprocessors and other specialized controllers, are used in disk-drive controllers and related devices, this invention describes the use of a general purpose microcontroller for magnetic card applications. Generally, magnetic card readers use synchronous digital logic circuits. The data must be processed as the information is read from the card in real time. This limits the card reader""s ability to process the data in depth for error and security check. An advantage of the present invention is that by using the microcontroller, the data can be processed after the information is read from the card.
Another advantage is that the use of the microcontroller allows less complicated electronic hardware, simplifies magneto resistive (MR) read/write head structure, and it provides an easy method to manipulate the data after it is read from the card. It also increases the reliability of the control system by reducing the number of electronic components. The microcontroller allows the implementation of efficient algorithms for decoding/encoding information along with security codes, and error detection schemes. The invented controller unit will be suitable for multi-track magnetic media with different bit density on each track.
Yet another advantage is that the entire read/write process will be accomplished by using microcontrollers rather than by digital logic gates and discrete components. This will increase the reliability of the system and it will lower the cost of the system.
Still yet another advantage is that the reading, processing, writing, and encryption/decryption of data is done by software rather than by a sequential logic decoding circuitry. Hence, it offers more flexibility and reliability, and lowers the cost in system implementation. The execution of the transactions can be handled by the same microcontroller.
Another advantage is that the thin film MR read/write heads can be fabricated with multiple of bit length distance between the MR read head and the write head. The novel design reduces cross-talk between the read head and write head.
The novel invention herein described takes advantage of the development in integrated circuits microcontrollers, and the development in hard disk technology namely magnetoresistive read heads. Microprocessors and microcontrollers with high speed are readily available and magnetoresistive heads provide more signal than inductive heads. The MR head signal is independent of the speed of the swipe/insertion and is independent of the direction of the swipe/insertion. This unique feature of the MR head makes it the ideal head for the magnetic card applications where the speed/direction of the swipe/insertion can vary.
An object of this invention is to provide a stand alone reader system for magnetic stripes. Another object of this invention is to provide the design of a stand alone reader/writer system for credit card and debit card applications. Yet another object of this invention is to use microcontroller/microprocessor chips to perform reading from the magnetic stripe cards and writing into the magnetic stripe card.
Another object of this invention is to provide a method for reading and writing while the speed of insertion or the swipe of the card varies with time. Still yet another object is to provide in the preferred embodiment a minimum of two bit cell distance between read head and the write head. Another object is to prevent data shifting on the track while the debit card is used. These and many other objects will become apparent with a reading of the detailed description of the preferred embodiments.